home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / webtp55.zip / TANGLE.CHG < prev    next >
Text File  |  1989-12-05  |  63KB  |  1,879 lines

  1. % This is TANGLE.CHG for TURBO Pascal 5.5
  2. %
  3. % (c) 1989 by Peter Sawatzki <FE617@DHAFEU11.BITNET>
  4. %             Buchenhof 3, D-5800 Hagen 1 (Dahl), Germany (West)
  5. %
  6. %  Change History:
  7. %
  8. %  Initials:   PS = Peter Sawatzki, FE617@DHAFEU11
  9. %  =========   WGS = Wayne G. Sullivan, WSULIVAN@IRLEARN
  10. %              PB = Peter Breitenlohner, PEB@DM0MPI11
  11. %
  12. %  rel.  date      Author  description
  13. %  ====  ====      ======  ===========
  14. %  v0.1  2-Mar-88  PS      initial TP3 release
  15. %  v0.2  5-May-88  PS      array-like macros: "()" solution
  16. %  v0.3 22-Aug-88  PS      copy some Inlines from WGS
  17. %  v0.4  3-Sep-88  PS      better handling of shl and shr
  18. %  v0.5  8-Dec-88  PS      better array-like macros based on PB's solution
  19. %  v0.6 10-Dec-88  PS      TurboPascal-like hex constants
  20. %  v0.7  3-Jun-89  PS      include the mod/and, div/shr optimization
  21. %  v0.8 29-Jul-89  PS      @i option: (nested) include files
  22. %  v0.9  1-Aug-89  PS      multiple change files
  23. %  v1.0  3-Aug-89  PS      Inline assembler implemented
  24. %  v1.1  5-Dec-89  PS      kill error in multiple change file handling
  25. %
  26. %  Tangle/Compile Instructions:
  27. %  ============================
  28. %  TANGLE TANGLE /d /m /c
  29. %  TPC /$A+,O-,E-,N-,B-,I-,V-,S-,D- /$M$5000,0,$2000 TANGLE /M
  30. %
  31. %
  32. % kludge fillchar firstvar -> lastvar inserted
  33. %
  34. ────────────────────────────────────────────────────────────────
  35. @x l.22 m.0
  36. \def\PASCAL{Pascal}
  37. @y
  38. \def\PASCAL{Pascal}
  39. \def\TP{\hbox{Turbo Pascal 5.5}}
  40. @z
  41. ────────────────────────────────────────────────────────────────
  42. @x l.36 m.0
  43.   \vfill}
  44. @y
  45.   \centerline{(Changes for \TP, 5-Dec-89)}
  46.   \vfill}
  47. @z
  48. ────────────────────────────────────────────────────────────────
  49. @x l.64 m.1
  50. @d banner=='This is TANGLE, Version 4'
  51. @y
  52. @d banner=='This is TANGLE, Version 4/TP55 1.1'
  53. @z
  54. ────────────────────────────────────────────────────────────────
  55. @x l.75 m.2
  56. @d end_of_TANGLE = 9999 {go here to wrap it up}
  57. @y
  58. @z
  59. ────────────────────────────────────────────────────────────────
  60. @x l.77 m.2
  61. @p @t\4@>@<Compiler directives@>@/
  62. program TANGLE(@!web_file,@!change_file,@!Pascal_file,@!pool);
  63. label end_of_TANGLE; {go here to finish}
  64. const @<Constants in the outer block@>@/
  65. type @<Types in the outer block@>@/
  66. var @<Globals in the outer block@>@/
  67. @y
  68. @p program TANGLE;
  69. uses
  70.   Asm2Inl;
  71. const @<Constants in the outer block@>@/
  72. type @<Types in the outer block@>@/
  73. const @<Typed constants in the outer block@>@/
  74. var @/
  75.   firstvar: byte; @/
  76.   @<Globals in the outer block@>@/
  77.   lastvar: byte; @/
  78. @<Inline procedures and functions@>@/
  79. @<All purpose procedures and functions@>@/
  80. @z
  81. ────────────────────────────────────────────────────────────────
  82. @x l.94 m.3
  83. @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
  84. @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
  85. @y
  86. @d ifdef(#)==@={$ifdef @>#@=}@>
  87. @d endif==@={$endif}@>
  88. @d debug==ifdef(deb)
  89. @d gubed==endif
  90. @d Asm(#)==inline(@[#@])
  91. @z
  92. ────────────────────────────────────────────────────────────────
  93. @x l.99 m.3
  94. @d stat==@{ {change this to `$\\{stat}\equiv\null$'
  95.   when gathering usage statistics}
  96. @d tats==@t@>@} {change this to `$\\{tats}\equiv\null$'
  97.   when gathering usage statistics}
  98. @y
  99. @d stat==ifdef(sta)
  100. @d tats==endif
  101. @z
  102. ────────────────────────────────────────────────────────────────
  103. @x l.114 m.4
  104. @<Compiler directives@>=
  105. @{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead}
  106. @!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging}
  107. @y
  108. @<Inline proc...@>=
  109. function mavail: word;
  110. Asm(mov ah,$48/   {allocate memory}
  111.     mov bx,$FFFF/ {determine free memory}
  112.     int $21/
  113.     mov ax,bx);   {return size of largest available block}
  114.  
  115. function malloc (no: word): word;
  116. Asm(mov ah,$48/   {allocate memory}
  117.     pop bx/       {no of bytes}
  118.     int $21/
  119.     jnc ok/       {no error}
  120.     xor ax,ax/    {clear ax in case of error}
  121.  ok: );
  122.  
  123. procedure mfree (segm: word);
  124. Asm(mov ah,$49/ {free memory}
  125.     pop es/     {segment to free}
  126.     int $21);
  127. @z
  128. ────────────────────────────────────────────────────────────────
  129. @x l.139 m.6
  130. @d incr(#) == #:=#+1 {increase a variable by unity}
  131. @d decr(#) == #:=#-1 {decrease a variable by unity}
  132. @d loop == @+ while true do@+ {repeat over and over until a |goto| happens}
  133. @d do_nothing == {empty statement}
  134. @d return == goto exit {terminate a procedure call}
  135. @f return == nil
  136. @f loop == xclause
  137. @y
  138. @d incr(#) == Inc(#) {increase a variable by unity}
  139. @d decr(#) == Dec(#) {decrease a variable by unity}
  140. @d loop == @+ while true do@+ {repeat over and over until a |goto| happens}
  141. @d do_nothing == {empty statement}
  142. @d return == @= exit @>
  143. @f return == nil
  144. @f loop == xclause
  145. @d void == begin end
  146. @z
  147. ────────────────────────────────────────────────────────────────
  148. @x l.168 m.7
  149. @d othercases == others: {default for cases not listed explicitly}
  150. @y
  151. @d othercases == else {default for cases not listed explicitly}
  152. @z
  153. ────────────────────────────────────────────────────────────────
  154. @x l.177 m.8
  155. @!buf_size=100; {maximum length of input line}
  156. @!max_bytes=45000; {|1/ww| times the number of bytes in identifiers,
  157.   strings, and module names; must be less than 65536}
  158. @!max_toks=50000; {|1/zz| times the number of bytes in compressed \PASCAL\ code;
  159.   must be less than 65536}
  160. @!max_names=4000; {number of identifiers, strings, module names;
  161.   must be less than 10240}
  162. @y
  163. @!buf_size=256; {maximum length of input line (must be |>255| for inline code)}
  164. @!max_max_bytes=8000;
  165. @!min_bytes=1000;
  166. @!step_bytes=1000;
  167. @!max_bytes: word = max_max_bytes;
  168.  {|1/ww| times the number of bytes in identifiers,
  169.   strings, and module names; must be less than 65536}
  170. @!max_max_toks = 15000;
  171. @!min_toks = 2000;
  172. @!step_toks = 2000;
  173. @!max_toks: word = max_max_toks;
  174.  {|1/zz| times the number of bytes in compressed \PASCAL\ code;
  175.   must be less than 65536}
  176. @!max_names=4600; {number of identifiers, strings, module names;
  177.   must be less than 10240}
  178. @z
  179. ────────────────────────────────────────────────────────────────
  180. @x l.190 m.8
  181. @!max_id_length=12; {long identifiers are chopped to this length, which must
  182.   not exceed |line_length|}
  183. @!unambig_length=7; {identifiers must be unique if chopped to this length}
  184.   {note that 7 is more strict than \PASCAL's 8, but this can be varied}
  185. @y
  186. @!max_id_length=30; {long identifiers are chopped to this length, which must
  187.   not exceed |line_length|}
  188. @!unambig_length=25; {identifiers must be unique if chopped to this length}
  189. @z
  190. ────────────────────────────────────────────────────────────────
  191. @x l.301 m.12
  192. @!text_file=packed file of text_char;
  193. @y
  194. @!text_file=Text;
  195. @ @d term_out==Output
  196. @z
  197. ────────────────────────────────────────────────────────────────
  198. @x l.303 m.13
  199. @ The \.{WEAVE} and \.{TANGLE} processors convert between ASCII code and
  200. the user's external character set by means of arrays |xord| and |xchr|
  201. that are analogous to \PASCAL's |ord| and |chr| functions.
  202.  
  203. @<Globals...@>=
  204. @!xord: array [text_char] of ASCII_code;
  205.   {specifies conversion of input characters}
  206. @!xchr: array [ASCII_code] of text_char;
  207.   {specifies conversion of output characters}
  208.  
  209. @ If we assume that every system using \.{WEB} is able to read and write the
  210. visible characters of standard ASCII (although not necessarily using the
  211. ASCII codes to represent them), the following assignment statements initialize
  212. most of the |xchr| array properly, without needing any system-dependent
  213. changes. For example, the statement \.{xchr[@@\'101]:=\'A\'} that appears
  214. in the present \.{WEB} file might be encoded in, say, {\mc EBCDIC} code
  215. on the external medium on which it resides, but \.{TANGLE} will convert from
  216. this external code to ASCII and back again. Therefore the assignment
  217. statement \.{XCHR[65]:=\'A\'} will appear in the corresponding \PASCAL\ file,
  218. and \PASCAL\ will compile this statement so that |xchr[65]| receives the
  219. character \.A in the external (|char|) code. Note that it would be quite
  220. incorrect to say \.{xchr[@@\'101]:="A"}, because |"A"| is a constant of
  221. type |integer|, not |char|, and because we have $|"A"|=65$ regardle